//
//  RW_PlayerItemCollectionViewCell.m
//  SleepApp
//
//  Created by MAC on 2021/4/8.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_PlayerItemCollectionViewCell.h"


@interface RW_PlayerItemCollectionViewCell (){
    RW_PlayerItemCollectionViewCellModel *_model;
}
/** 歌曲背景图 */
@property (nonatomic,strong) UIImageView *wlclass_bg_image_view;
/** 歌曲名 */
@property (nonatomic,strong) UILabel *wlclass_title_label;
/** 歌曲描述 */
@property (nonatomic,strong) UILabel *wlclass_desc_label;
@end
@implementation RW_PlayerItemCollectionViewCell

-(void)bind_row_data:(WLBaseCollectionViewLayerRow *)sender{
    if ([sender.data isKindOfClass:RW_PlayerItemCollectionViewCellModel.class]){
        _model = sender.data;
        [self.wlclass_bg_image_view wl_setImage:_model.song_cover_url];
        self.wlclass_title_label.text = _model.song_name_string;
        self.wlclass_desc_label.text = _model.song_desc_string;
    }
}
-(void)bind_delegate:(id)sender{
    
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColor.clearColor;
        [self addSubview:self.wlclass_bg_image_view];
        [self addSubview:self.wlclass_title_label];
        [self addSubview:self.wlclass_desc_label];

        [self.wlclass_bg_image_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsZero);
        }];
        [self.wlclass_title_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.top.mas_equalTo(self).mas_offset(kNavBarAndStatusBarHeight);
        }];
        [self.wlclass_desc_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).mas_offset(50);
            make.right.mas_equalTo(self).mas_offset(-50);
            make.bottom.mas_equalTo(self).mas_offset(- 190 - kBottomSafeHeight);
        }];
    }
    return self;
}
#pragma mark -- 操作
#pragma mark -- 懒加载
-(UIImageView *)wlclass_bg_image_view{
    if (!_wlclass_bg_image_view){
        _wlclass_bg_image_view = [[UIImageView alloc]init];
        _wlclass_bg_image_view.alpha = .5f;
    }
    return _wlclass_bg_image_view;
}
-(UILabel *)wlclass_title_label{
    if (!_wlclass_title_label){
        _wlclass_title_label = [[UILabel alloc]init];
        _wlclass_title_label.font = [UIFont systemFontOfSize:32 weight:UIFontWeightMedium];
    }
    return _wlclass_title_label;
}
-(UILabel *)wlclass_desc_label{
    if (!_wlclass_desc_label){
        _wlclass_desc_label = [[UILabel alloc]init];
        _wlclass_desc_label.textAlignment = NSTextAlignmentCenter;
        _wlclass_desc_label.numberOfLines = 3;
    }
    return _wlclass_desc_label;
}
@end


@implementation RW_PlayerItemCollectionViewCellModel
-(id)obj_model{
    if (!_obj_model){
        if (self.user_song_model){
            _obj_model = self.user_song_model;
        } else if (self.song_model){
            _obj_model = self.song_model;
        }
    }
    return _obj_model;
}
-(NSString *)song_cover_url{
    if (!_song_cover_url){
        if (self.user_song_model){
            _song_cover_url = self.user_song_model.cover;
        } else if (self.song_model){
            _song_cover_url = self.song_model.cover;
        } else {
            _song_cover_url = @"";
        }
    }
    return _song_cover_url;
}
-(NSString *)song_name_string{
    if (!_song_name_string){
        if (self.user_song_model){
            _song_name_string = self.user_song_model.name;
        } else if (self.song_model){
            _song_name_string = self.song_model.name;
        } else {
            _song_name_string = @"";
        }
    }
    return _song_name_string;
}
-(NSString *)song_desc_string{
    if (!_song_desc_string){
        if (self.user_song_model){
            _song_desc_string = self.user_song_model.desc;
        } else if (self.song_model){
            _song_desc_string = self.song_model.desc;
        } else {
            _song_desc_string = @"";
        }
    }
    return _song_desc_string;
}
@end
